<?php
namespace app\index\model;
use think\Model;
use think\Session;
class Logins extends Model
{
	protected $resultSetType = 'collection';
	public function checkLogin($account,$root){
		$db = db('admin')->where('account',$account)->find();
		if($db){
			if($db['root']==md5($root).$db['randomcode']){
				Session::set('account',$db['account']);
                Session::set('id',$db['id']);
                Session::set('isadmin',$db['isadmin']);
                session_write_close();
				return 1;
			}
			else{
				return 2;
			}
		}
		else{
			return 2;
		}
	}

}